package com.me.template4j.pojo;

import org.springframework.http.HttpStatus;

import java.io.Serializable;

/**
 * @Author qiu
 * @create 2020/2/14 15:20
 */
public class ResultBean<T> implements Serializable {

    /**
     * 接口返回状态 200: 正常返回
     *           500: 有错误
     */
    private Integer statusCode;

    private T content;

    private String info;

    public ResultBean() {
    }

    public ResultBean(HttpStatus status, T content) {
        this.statusCode = status.value();
        this.content = content;
    }

    public ResultBean(HttpStatus status, T content,String info) {
        this.statusCode = status.value();
        this.content = content;
        this.info = info;
    }
    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer status_code) {
        this.statusCode = status_code;
    }

    public T getContent() {
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public static<T> ResultBean<T> ok() {
        return new ResultBean<>(HttpStatus.OK,null,"操作成功");
    }
    
    public static<T> ResultBean<T> ok(T content) {
        return new ResultBean<>(HttpStatus.OK,content,"操作成功");
    }

    public static<T> ResultBean<T> error() {
        return new ResultBean<>(HttpStatus.INTERNAL_SERVER_ERROR,null,"操作失败");
    }
}
